package com.cloudfun.campusshare.service.handler;

import cn.hutool.core.bean.BeanUtil;
import com.cloudfun.campusshare.common.model.dto.kjt.KjtNotifyBaseDTO;
import com.cloudfun.campusshare.common.model.dto.kjt.KjtSubMerchantRegNotifyDTO;
import com.cloudfun.campusshare.common.model.dto.kjt.KjtSubMerchantRegRespDTO;
import com.cloudfun.campusshare.service.KjtSubMerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 处理注册结果通知
 * Created by Huqin on 2020/8/17
 */
@Component
public class KjtRegisterNotifyHandler implements KjtNotifyHandler<KjtSubMerchantRegNotifyDTO> {

    @Autowired
    private KjtSubMerchantService kjtSubMerchantService;

    @Override
    public String notifyType() {
        return "register_sync";
    }

    @Override
    public Class<KjtSubMerchantRegNotifyDTO> notifyMessageType() {
        return KjtSubMerchantRegNotifyDTO.class;
    }

    @Override
    public boolean handle(KjtNotifyBaseDTO notifyMsg) {
        KjtSubMerchantRegRespDTO regRespDTO = new KjtSubMerchantRegRespDTO();
        BeanUtil.copyProperties(notifyMsg, regRespDTO);
        kjtSubMerchantService.handleRegResponse(regRespDTO);
        return true;
    }
}
